package com.takeoutsystem.event.message;

import com.takeoutsystem.bean.StorageRemainShow;
import org.springframework.context.ApplicationEvent;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;


public class GetOrderMailEvent extends ApplicationEvent {
    /**
     * 外卖订单信息
     */
    private StorageRemainShow orderInfo;

    public GetOrderMailEvent(Object source,StorageRemainShow orderInfo) {
        super(source);
        this.orderInfo=orderInfo;
    }

    public StorageRemainShow getOrderInfo() {
        return orderInfo;
    }

    public void setOrderInfo(StorageRemainShow orderInfo) {
        this.orderInfo = orderInfo;
    }

    /**
     * 生成短信内容
     * @return
     */
    public String generateMailContent(){
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        return "【饿团外卖】您的外卖于"+dateFormat.format(orderInfo.getInTime())+"存放于自提柜"+orderInfo.getCabId()+";请凭取餐号"+
                orderInfo.getUserTel().substring(orderInfo.getUserTel().length()-4)+
                "及时取餐。外卖存放超过12h将被清除!";
    }
}
